package org.example.juc.sync.v5;


/**
 * Copyright (C), 2022, szw
 * FileName: SynchronizedTestV5
 *
 * @author songyafei
 * Date:     2022/1/25 9:37
 * Description: 版本5
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
public class SynchronizedTestV5 implements Runnable{


    private   int count = 100;

    @Override
    public synchronized void run() {
        count--;
        System.out.println(Thread.currentThread().getName() + " count = " + count);
    }

    public static void main(String[] args) {
        SynchronizedTestV5 t = new SynchronizedTestV5();
        SynchronizedTestV5 t1 = new SynchronizedTestV5();
        for(int i=0; i<100; i++) {
            new Thread(t, "THREAD" + i).start();
        }

        for(int i=0; i<100; i++) {
            new Thread(t1, "THREAD-TWO" + i).start();
        }
    }
}
